package com.mate.cloud.chain.handler;

import com.mate.cloud.chain.constant.MembershipLevel;
import com.mate.cloud.chain.domain.User;

/**
 * 具体处理者
 *
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2024/6/1 15:32
 * @updateUser: MI
 * @updateTime: 2024/6/1 15:32
 * @updateRemark: 修改内容
 * @version: v1.0
 */
public class BasicMemberDiscountHandler extends DiscountHandler {
    @Override
    public double applyDiscount(double amount, User user) {
        if (user.getMembershipLevel() == MembershipLevel.BASIC) {
            // Basic会员享受5%折扣
            return amount * 0.95;
        } else if (nextHandler != null) {
            return nextHandler.applyDiscount(amount, user);
        } else {
            // 如果没有下一个处理者，则不打折
            return amount;
        }
    }
}
